/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author longdm0708l
 */
@Entity
@Table(name = "Warehouse")
@NamedQueries({@NamedQuery(name = "Warehouse.findAll", query = "SELECT w FROM Warehouse w"), @NamedQuery(name = "Warehouse.findByWarehouseId", query = "SELECT w FROM Warehouse w WHERE w.warehouseId = :warehouseId"), @NamedQuery(name = "Warehouse.findByWarehouseName", query = "SELECT w FROM Warehouse w WHERE w.warehouseName = :warehouseName"), @NamedQuery(name = "Warehouse.findByLocation", query = "SELECT w FROM Warehouse w WHERE w.location = :location")})
public class Warehouse implements Serializable {
    private static final long serialVersionUID = 1L;
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Id
    @Basic(optional = false)
    @Column(name = "WarehouseId")
    private Integer warehouseId;
    @Basic(optional = false)
    @Column(name = "WarehouseName")
    private String warehouseName;
    @Basic(optional = false)
    @Column(name = "Location")
    private String location;
    @JoinColumn(name = "CompanyId", referencedColumnName = "CompanyId")
    @ManyToOne
    private Company companyId;
    @OneToMany(mappedBy = "warehouseId")
    private Collection<Product> productCollection;

    public Warehouse() {
    }

    public Warehouse(Integer warehouseId) {
        this.warehouseId = warehouseId;
    }

    public Warehouse(Integer warehouseId, String warehouseName, String location) {
        this.warehouseId = warehouseId;
        this.warehouseName = warehouseName;
        this.location = location;
    }

    public Integer getWarehouseId() {
        return warehouseId;
    }

    public void setWarehouseId(Integer warehouseId) {
        this.warehouseId = warehouseId;
    }

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Company getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Company companyId) {
        this.companyId = companyId;
    }

    public Collection<Product> getProductCollection() {
        return productCollection;
    }

    public void setProductCollection(Collection<Product> productCollection) {
        this.productCollection = productCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (warehouseId != null ? warehouseId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Warehouse)) {
            return false;
        }
        Warehouse other = (Warehouse) object;
        if ((this.warehouseId == null && other.warehouseId != null) || (this.warehouseId != null && !this.warehouseId.equals(other.warehouseId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.Warehouse[warehouseId=" + warehouseId + "]";
    }

}
